package com.fy.consumer.controller;

import com.fy.common.api.CommonResult;
import com.fy.common.util.BeansUtil;
import com.fy.consumer.vo.TravelOrderVo;
import com.fy.order.api.TravelOrderService;
import com.fy.order.dto.TravelOrderDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/consumer/order")
@Api(tags = "消费者订单管理")
public class ConsumerOrderController {

    @Autowired
    private TravelOrderService travelOrderService;

    /**
     * @param
     * @return com.fasterxml.jackson.databind.util.JSONPObject
     * @author Sun-qw
     * @date 2022/5/25 18:29
     */
    @ApiOperation("查询消费者全部订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "consumerId", value = "消费者id"),
            @ApiImplicitParam(name = "type", value = "类型（门票 ，实物）")
    })
    @GetMapping(value = "/orderFindByConsumerId")
    public CommonResult orderFindByConsumerId(Integer consumerId, String type) {
        List<TravelOrderVo> travelOrderVoList = null;
        return CommonResult.success(travelOrderVoList);
    }

    /**
     * @param travelOrderId
     * @return com.fy.consumer.vo.TravelOrderVo
     * @author Sun-qw
     * @date 2022/5/27 16:39
     */
    @ApiOperation("查询消费者订单详情信息")
    @ApiImplicitParam(name = "travelOrderId", value = "订单id")
    @GetMapping(value = "/travelOrderFindByTravelOrderId")
    public CommonResult travelOrderFindByTravelOrderId(Integer travelOrderId) {
        TravelOrderDto travelOrderDto = travelOrderService.travelOrderFindById(travelOrderId);
        TravelOrderVo travelOrderVo = null;
        BeanUtils.copyProperties(travelOrderDto,travelOrderVo);
        return CommonResult.success(travelOrderVo);
    }

    /**
     * @param orderId
     * @param type
     * @return int
     * @author Sun-qw
     * @date 2022/5/27 14:52
     */
    @ApiOperation("消费者修改订单信息(评价等)")
    @PostMapping(value = "/updateComment")
    public CommonResult updateTravelOrder(int orderId,int type) {
        TravelOrderVo travelOrderVo = null;
        return CommonResult.success(travelOrderVo);
    }
}
